/**
 * Copyright [2012-2013] [Guðmundur Björn Birkisson]
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License. Copyright [2012-2013] [Guðmundur Björn Birkisson]
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * ---------------------------------------------------------------------------
 * 
 * Class name:  KcIsOnRock
 * 
 * Description of class:
 * 
 * Concrete KarelCommand.
 * 
 */

package karel.gamelogic.commands;

import karel.gamelogic.GameContainer;
import karel.gamelogic.world.KarelMap;
import karel.gamelogic.world.KarelRobot;
import karel.gamelogic.world.Tile;
import karel.graphics.Renderer;


public class KcIsOnRock extends KarelCommand {
    
    private float timer;
    private boolean onRock;
    
    public KcIsOnRock(KarelRobot robot, Renderer renderer, KarelMap map) {
        super(robot, renderer);
        timer = 0.0f;
        onRock = map.isType(robot.postition,Tile.Type.ROCK);
    }
    
    @Override
    public void update() {
        if(timer++ > GameContainer.gameAnimationSpeed) {
            commandDone = true;
        }
    }

    @Override
    public Object getCommandReturnValue() {
        return onRock;
    }
}
